#include <cstdio>

const int N = 1000005, mod = 1e9 + 7;
int n;
int p[N], f[N], sum[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("Doughnut.in", "r", stdin);
  freopen("Doughnut.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &p[i]);
  }
  for (int i = 1; i <= n; ++i) {
    f[i] = (((((sum[i - 1] - sum[p[i] - 1]) % mod - p[i]) % mod + i) % mod + 1) % mod + mod) % mod;
    sum[i] = (sum[i - 1] + f[i]) % mod;
  }
  printf("%d", (sum[n] + n) % mod);
  return 0;
}